﻿// Keep user from entering more than maxLength characters
function doKeypress(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
//    var TB = document.getElementById("ctl00_ctl00_ContentPlaceHolder3_ContentPlaceHolder1_WriteOnWallTextBox");
//    TB.title = maxLength - value.length;
    //control.attributes["title"] = 'Some other tooltip';
    //control.attr('title', 'Some other tooltip');
    document.getElementById("remLength").value = maxLength - value.length;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}
// Cancel default behavior
function doBeforePaste(control){
    alert("before paste");
    maxLength = control.attributes["maxLength"].value;
     if(maxLength) {
         alert("maxlength is true: " + maxLength);
         event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control) {
    alert("pasting");
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
    if (maxLength) {
        alert("maxlength is true: " + maxLength);
        event.returnValue = false;
        maxLength = parseInt(maxLength);
        var oTR = control.document.selection.createRange();
        var iInsertLength = maxLength - value.length + oTR.text.length;
        var sData = window.clipboardData.getData("Text").substr(0, iInsertLength);
        oTR.text = sData;
    }

   

}